//
//  DBValueSuper.h
//  CareRingApp
//
//  Created by Linktop on 2022/6/7.
//

#import <Foundation/Foundation.h>
#import "HMDBManager.h"

#define DB_WEAK_SELF  __weak typeof(self) weakSelf = self;
#define DB_STRONG_SELF  __strong typeof(weakSelf) strongSelf = weakSelf;

NS_ASSUME_NONNULL_BEGIN

@interface DBValueSuper : NSObject

@property(assign, nonatomic)int cId;
@property(strong, nonatomic)NSDate *time;
@property(strong, nonatomic)NSNumber *value;
@property(strong, nonatomic)NSString *macAddress; //所属用户的账号
@property(strong, nonatomic)NSNumber *battery;


+(void)createTable:(NSString *)tableName;


-(instancetype)initWith:(NSDate *)time Value:(NSNumber *)value Account:(NSString *)account;


+(void)queryAverage:(NSString * _Nonnull)account Begin:(NSDate *)beginDate End:(NSDate *)endDate TableName:(NSString *)tableName Cpmplete:(void(^)(NSNumber * _Nullable average, NSNumber * _Nullable maxTime,  NSNumber * _Nullable minTime ) )cmpBlk;

-(void)insertBy:(NSString *)tableName CMP:(void(^)(BOOL succ))complete;

+(void)queryMutiDataGroupHours:(NSString * _Nonnull)account DayDate:(NSDate *)dayDate  TableName:(NSString *)tableName Cpmplete:(void(^)(NSMutableArray<NSDictionary *> * res) )cmpBlk;

/// 查询账号关联的数据的最大时间戳
/// @param account 账号
/// @param tableName 表名
/// @param cmpBlk 回调
+(void)queryMaxTime:(NSString * _Nonnull)account TableName:(NSString *)tableName Cpmplete:(void(^)(NSNumber * _Nullable maxTimeStamp) )cmpBlk;

//+(void)deleteAll:(NSString *)tableName;
//+(void)deleteAll;
@end

NS_ASSUME_NONNULL_END
